home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / comm / tcp / netinput37_3.lha / NetInput / source / unixsem.doc < prev    next >
Text File  |  1995-07-14  |  4KB  |  128 lines

  1. TABLE OF CONTENTS
  2.  
  3. sinit
  4. sset
  5. ssignal
  6. swait
  7. sinit                                                                    sinit
  8.  
  9.     NAME
  10.         sinit - Initialize a semaphore for use.
  11.  
  12.     SYNOPSIS
  13.         #include <unixsem.h>
  14.  
  15.         extern void sinit
  16.         (
  17.             CountSemaphore *sem,
  18.             ULONG sigmask
  19.         );
  20.  
  21.     INPUTS
  22.         CountSemaphore *sem
  23.             Pointer to a semaphore.
  24.             
  25.         ULONG sigmask
  26.             Exec signal-mask to be used for waiting
  27.             operations or -1 to used UNIXSEM_SIGMASK.
  28.  
  29.     FUNCTION
  30.         This sets various private fields.
  31.         The user may provide an Exec style signal-mask which should be used
  32.         for waiting operertions concerning THIS semaphore. If signal is
  33.         equal to -1, the default signal-mask UNIXSEM_SIGMASK is used. This
  34.         is defined in "unixsem.h" And may be altered with succeeding recompilation
  35.         of ALL modules using the semaphore calls.
  36.         The unit counter is set to zero.
  37.  
  38.     SEE ALSO
  39.         sset(), ssignal(), swait()
  40. sset                                                                      sset
  41.  
  42.     NAME
  43.         sset - Set a semaphore to a certain value.
  44.  
  45.     SYNOPSIS
  46.         #include <unixsem.h>
  47.  
  48.         extern void sset
  49.         (
  50.             CountSemaphore *sem,
  51.             LONG val
  52.         );
  53.  
  54.     INPUTS
  55.         CountSemaphore *sem
  56.             Pointer to a semaphore.
  57.             
  58.         LONG val
  59.             Value the semaphore should be assigned.
  60.  
  61.     FUNCTION
  62.         This is done independent of
  63.         any task possibly waiting fo the semaphore. Therefore this function
  64.         should only be called prior to any call of ssignal() or swait().
  65.         To create a mutual exclusion semaphore for protected areas of code,
  66.         te following sequence is appropriate:
  67.         
  68.         Sinit(&mutex,-1);
  69.         sset(&mutex,1);
  70.         
  71.         Anybody who wants to enter the protected area later should
  72.         perform these steps:
  73.         
  74.         Swait(&mutex);
  75.         protected area here
  76.         ssignal(&mutex);
  77.         
  78.         This has, of course, the same result as an according ObainSemaphore()/
  79.         ReleaseSemaphore() construct, but might be useful when porting UNIX
  80.         applications.
  81.  
  82.     SEE ALSO
  83.         sinit(), ssignal(), swait()
  84. ssignal                                                                ssignal
  85.  
  86.     NAME
  87.         ssignal - Increment the unit counter of a semaphore.
  88.  
  89.     SYNOPSIS
  90.         #include <unixsem.h>
  91.  
  92.         extern void ssignal(CountSemaphore *sem);
  93.  
  94.     INPUTS
  95.         CountSemaphore *sem
  96.             Pointer to a semaphore.
  97.  
  98.     FUNCTION
  99.         If there are any tasks waiting
  100.         for a unit, the chronologically first waiter will be awakened.
  101.  
  102.     SEE ALSO
  103.         sinit(), sset(), swait()
  104. swait                                                                    swait
  105.  
  106.     NAME
  107.         swait - Decrement the unit count of a semaphore.
  108.  
  109.     SYNOPSIS
  110.         #include <unixsem.h>
  111.  
  112.         extern void swait(CountSemaphore *sem);
  113.  
  114.     INPUTS
  115.         CountSemaphore *sem
  116.             Pointer to a semaphore.
  117.  
  118.     FUNCTION
  119.         If the unit count before the
  120.         call to swait() was less or equal to zero, the task will be added
  121.         to the semaphore's waiting space and fall asleep until sombody
  122.         calls ssignal() to the semaphore. If there are already other tasks
  123.         within the waiting space, these will be waked up first, before your
  124.         task is.
  125.  
  126.     SEE ALSO
  127.         sinit(), sset(), ssignal()
  128.